// JavaScript Document

function sidebarMonitor(opt_options){ //{toolsText}
  this.opts = opt_options||{};
}

sidebarMonitor.prototype = new GControl();
sidebarMonitor.prototype.initialize = function(_map) {
  openText = this.opts.monitorText||"Monitor";
  openerDiv = createElem("containMonitorLabel",openText); // open button
  with (openerDiv.style) {
  	borderRight = "1px solid #B0B0B0";
  	borderBottom = "1px solid #B0B0B0";
  	paddingTop = "1px";
  	paddingLeft = "4px";
    textAlign = "left";
    fontSize = "12px";
    fontFamily = "Arial";
    fontWeight = "Bold";
    background = "#FFFFFF";
    backgroundImage = "url('images/down.gif')";
    backgroundRepeat = "no-repeat";
    backgroundPosition = "right";
    width = "80px";
    cursor = "pointer";
  }
  _map.getContainer().appendChild(openerDiv);
  
  headerCont = createElem("sideblock-header"); // header contenedor del titulo y del close button
  headerCont.style.textAlign = "left";
  titleBlockText = this.opts.titleBar||"Titulo";
  titleBlock = createElem("sideblock-title",titleBlockText,"span");
  //header.appendChild(titleBlock);
  PanelTabImg = createElem("PanelTabImg");
  headerCont.appendChild(PanelTabImg);
  PanelTabImg.appendChild(titleBlock);
  closeDiv = createElem("sideblock-close-div");
  closeText = this.opts.closeText||"[x]&nbsp;";
  close = createElem("sideblock-close",closeText,"span"); // close button
  close.style.cursor = "pointer";
  closeDiv.appendChild(close);
  headerCont.appendChild(closeDiv);
  leftBar = createElem("sideblock"); // the parent element of the sidebar
  leftBar.appendChild(headerCont);
  _map.getContainer().appendChild(leftBar);
  leftBar.style.width = this.opts.sideBlockWidth||"400px";
  leftBar.style.height = this.opts.sideBlockHeight||"230px";
  contents = createElem("sideblock-container"); //contents div
  leftBar.appendChild(contents);
  contents.style.height = "90%";
  contents.style.overflow = "auto";
  me = this;
  me.container = contents;
  me.isVisible = true;
  function openEvent(){me.isVisible=true; monitorActivoFlag=true; GEvent.trigger(me,'open',true)};
  function closeEvent(){me.isVisible=false; monitorActivoFlag=false; GEvent.trigger(me,'close',false)};
  me.show = function(){leftBar.style.display = "block"; openEvent()};
  me.hide = function(){leftBar.style.display = "none"; closeEvent()};
  close.onclick = function(){me.hide()};
  openerDiv.onclick = function(){me.show()};
  return leftBar;
}

sidebarMonitor.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(95, 7));
}
